local skel = fk.CreateSkill{
  name = "tea__zhaofu",
  tags = { Skill.Limited, Skill.Lord }
}
--local U = require "packages/utility/utility"
Fk:loadTranslationTable{
  ["tea__zhaofu"] = "诏缚",
  [":tea__zhaofu"] = "主公技，限定技，准备阶段，你可以横置一名其他角色，直到其下次重置前，吴势力角色对其使用牌无次数限制且其不能响应。",
  ["#tea__zhaofu-invoke"] = "诏缚：你可以横置一名其他角色，直到其下次重置前，吴势力角色对其使用牌无次数限制且其不能响应",
  ["@@tea__zhaofu"] = "诏缚",
}
---@type TrigSkelSpec<PhaseFunc>
local zhaofu = {
  anim_type = "control",
  can_trigger = function (self, event, target, player, data)
    return player == target and player:hasSkill(skel.name) and player.phase == Player.Start
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local to = room:askToChoosePlayers(player, {
      targets = table.filter(room:getOtherPlayers(player), function (p)
        return not p.chained
      end),
      min_num = 1,
      max_num = 1,
      skill_name = skel.name,
      prompt = "#tea__zhaofu-invoke"
    })
    if #to == 1 then
      event:setCostData(self, { to = to[1] })
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local to = event:getCostData(self).to ---@type ServerPlayer
    local room = player.room
    room:setPlayerMark(to, "@@tea__zhaofu", 1)
    to:setChainState(true)
  end
}
---@type TrigSkelSpec<TrigFunc>
local zhaofu_delay = {
  can_refresh = function (self, event, target, player, data)
    return player == target and not target.chained and target:getMark("@@tea__zhaofu") ~= 0
  end,
  on_refresh = function (self, event, target, player, data)
    player.room:setPlayerMark(target, "@@tea__zhaofu", 0)
  end
}
---@type TargetModSpec
local zhaofu_targetmod = {
  bypass_times = function (self, player, skill, scope, card, to)
    return player.kingdom == "wu" and to:getMark("@@tea__zhaofu") ~= 0 and to.chained
  end
}
---@type TrigSkelSpec<UseCardFunc>
local zhaofu_buff = {
  anim_type = "offensive",
  can_refresh = function(self, event, target, player, data)
    return target == player and player.kingdom == "wu"
  end,
  on_refresh = function(self, event, target, player, data)
    data.disresponsiveList = data.disresponsiveList or {}
    for _, p in ipairs(player.room:getOtherPlayers(player, false)) do
      if p:getMark("@@tea__zhaofu") ~= 0 then
        table.insertIfNeed(data.disresponsiveList, p)
      end
    end
  end,
}
skel:addEffect(fk.EventPhaseStart, zhaofu)
skel:addEffect(fk.ChainStateChanged, zhaofu_delay)
skel:addEffect("targetmod", zhaofu_targetmod)
skel:addEffect(fk.CardUsing, zhaofu_buff)
-- Fk.generals["mouxusheng"]:addSkill(skel.name)
return skel